package com.lagou.handler;

import com.lagou.util.JsonMsg;
import com.lagou.util.LogUtils;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * @Author: lishuangqiang
 * @Date: 2020/4/17
 * @Description:
 */

public class JsonMsgHandler extends ChannelInboundHandlerAdapter {
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        String json = (String) msg;
        JsonMsg jsonMsg = JsonMsg.parseFromJson(json);
        LogUtils.info("收到一个 Json 数据包 =》" + jsonMsg.toString());
        ctx.writeAndFlush("success");

    }
}
